

<div class="layui-form" lay-filter="layuiadmin-form-role" id="form">
	<div class="form-cont">
		<div class="layui-form-item">
		  <label class="layui-form-label">开户行</label>
		  <div class="layui-input-block">
			  <input type="text" lay-verify="required" v-model="detail.bank_name" placeholder="请输入开户行" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
		  <label class="layui-form-label">开户人</label>
		  <div class="layui-input-block">
			  <input type="text" lay-verify="required" v-model="detail.account_name" placeholder="请输入开户人" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
		  <label class="layui-form-label">卡号</label>
		  <div class="layui-input-block">
			  <input type="text" lay-verify="required" v-model="detail.bank_account" placeholder="请输入卡号" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
		  <label class="layui-form-label">绑定手机号</label>
		  <div class="layui-input-block">
			  <input type="text" lay-verify="required" v-model="detail.account_phone" placeholder="请输入手机号" class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
		  <label class="layui-form-label">状态</label>
		  <div class="layui-input-block">
		      <div class="layui-unselect layui-form-switch" :class="{'layui-form-onswitch':detail.bank_status==1}" lay-skin="_switch" @click="radioF()"><em>{{detail.bank_status==1?'启用':'停用'}}</em><i></i></div>
		  </div>
		</div>
	</div>
  <div class="form-btn" v-if="type!=3">
      <input type="button" lay-submit lay-filter="form-submit" value="确认" class="layui-btn">
  </div>
</div>

<script>
	layui.use(['form'], function(){
	  var $ = layui.$
	  ,form = layui.form;
	  var forms=new Vue({
	  		el:'#form',
	  		data:{
	  			detail:{
					bank_status:1
				},
				old_detail:{},
				type:layui.admin.objData.type
	  		},
	  		mounted() {
				//初始化
	  			if(this.type!=1) this.detail=layui.admin.objData.detail,this.old_detail=JSON.stringify(layui.admin.objData.detail);
				//提交form
				var _this=this;
				form.on('submit(form-submit)',function(data){
					if(_this.type==2){   //编辑
						var data=layui.admin.filter(_this.detail,JSON.parse(_this.old_detail),'bank_id');
						if(data){
							layui.admin.formapi('agent_bank/update',data);
						}
					}else{  //添加
						layui.admin.formapi('agent_bank/add',_this.detail);
					}
				})
	  		},
	  		methods:{
	  			radioF(){//radio选择
	  				this.detail.bank_status==1?this.detail.bank_status=2:this.detail.bank_status=1;
	  			}
	  		}
	  	})
	});
</script>
